<extend name="Base/common"/>
<block name="style">
    <style type="text/css">
    .head_head{
        height:20%;
        width:100%;

    }
    .head_label{
        width: 100%;
        display: block;
        text-align: center;
        font-size: 16px;

    }
    .head_value{
        width: 100%;
        margin-top: -15px;
        display: block;
        text-align: center;
        font-size: 30px;
        color:#000;

    }
    .head_daoqi{
        width: 100%;
        display: block;
        height:20px;
        margin-top: -15px;
        text-align: center;
        font-size: 12px;


    }

    </style>
</block>
<block name="body">
<div style="position:relative;">
    <div class="page__bd" >

        <div class="weui-form-preview">


            <div class="weui-form-preview__bd">
                <if condition="$info[status] eq 5">
                    <span class="head_label">待还款金额</span>
                <elseif condition="$info[status] eq 6"/>
                    <span class="head_label">已还款金额</span>
                <else/>
                    <span class="head_label">借款金额</span>
                </if>
                <span class="head_value"> {$info.repayment}</span>

                <if condition="$info[status] eq 1">
                    <span class="head_daoqi" style="color:orange;">待审核</span>
                <elseif condition="$info[status] eq 2"/>
                    <span class="head_daoqi" style="color:orange;">审核中</span>
                <elseif condition="$info[status] eq 3"/>
                    <span class="head_daoqi" style="color:red;">不通过</span>
                <elseif condition="$info[status] eq 4"/>
                    <span class="head_daoqi" style="color:orange;">待打款</span>
                <elseif condition="$info[status] eq 5"/>
                    <span class="head_daoqi" style="color:orange;">最后还款日期：{$info.expire_time|date='Y-m-d H:i:s',###}</span>
                <elseif condition="$info[status] eq 6"/>
                    <span class="head_daoqi" style="color:green;">已还款</span>
                <elseif condition="$info[status] eq -1"/>
                    <span class="head_daoqi" style="color:red;">已取消</span>
                </if>
                
            </div>


            <div class="weui-form-preview__bd">
                <div class="weui-form-preview__item" style="position:relative;">
                    <if condition="$info[status] eq 1">
                        <label class="weui-form-preview__label">合同编号</label>
                        <span class="weui-form-preview__value" >{$info.id} </span>
                    <elseif condition="$info[status] eq 2"/>
                        <label class="weui-form-preview__label">合同编号</label>
                        <span class="weui-form-preview__value" >{$info.id} </span>
                    <elseif condition="$info[status] eq 3"/>
                        <label class="weui-form-preview__label">合同编号</label>
                        <span class="weui-form-preview__value" >{$info.id} </span>
                    
                    <elseif condition="$info[status] eq 6"/>
                        <label class="weui-form-preview__label">合同编号</label>
                        <span class="weui-form-preview__value" >{$info.id} </span>
                    <elseif condition="$info[status] eq -1"/>
                        <label class="weui-form-preview__label">合同编号</label>
                        <span class="weui-form-preview__value" >{$info.id} </span>
                    <else/>
                        <a href="http://weixin.jcsmkj.cn/index.php?m=weixin&c=capital&a=agreement&show=1&id={$info.id}">
                            <label class="weui-form-preview__label">合同编号</label>
                            <span class="weui-form-preview__value" >{$info.id} <b style="color:#ccc;font-weight: normal;margin_left:2px;">></b></span>
                        </a>
                    </if>


                    
                </div>
                <div class="weui-form-preview__item">
                    <label class="weui-form-preview__label">借款金额</label>
                    <span class="weui-form-preview__value">¥{$info.money}</span>
                </div>

                <div class="weui-form-preview__item">
                    <label class="weui-form-preview__label">信审核费</label>
                    <span class="weui-form-preview__value">¥{$info.vetting1}</span>
                </div>
                <div class="weui-form-preview__item">
                    <label class="weui-form-preview__label">借款利息</label>
                    <span class="weui-form-preview__value">¥{$info.accrual}</span>
                </div>
                <div class="weui-form-preview__item">
                    <label class="weui-form-preview__label">帐户管理费</label>
                    <span class="weui-form-preview__value">¥{$info.manag}</span>
                </div>
                <div class="weui-form-preview__item">
                    <label class="weui-form-preview__label">借款天数</label>
                    <span class="weui-form-preview__value">{$info.day}天</span>
                </div>
                <div class="weui-form-preview__item">
                    <label class="weui-form-preview__label">申请时间</label>
                    <span class="weui-form-preview__value">{$info.create_time|date='Y-m-d H:i:s',###}</span>
                </div>
                <if condition="$info['status'] gt 4">
                    <div class="weui-form-preview__item">
                        <label class="weui-form-preview__label">借款时间</label>
                        <span class="weui-form-preview__value">{$info.loan_time|date='Y-m-d H:i:s',###}</span>
                    </div>
                    <div class="weui-form-preview__item">
                        <label class="weui-form-preview__label">还款期限</label>
                        <span class="weui-form-preview__value">{$info.expire_time|date='Y-m-d H:i:s',###}</span>
                    </div>
                    <div class="weui-form-preview__item">
                        <label class="weui-form-preview__label">还款日期</label>
                        <if condition="$info[huankuan_time] eq 0">
                            <span class="weui-form-preview__value">待还款</span>
                        <else/>
                            <span class="weui-form-preview__value">{$info.huankuan_time|date='Y-m-d H:i:s',###}</span>
                        </if>
                    </div>
                </if>

                <div class="weui-form-preview__item">
                    <label class="weui-form-preview__label">借款状态</label>
                    <php>
                        $LOAN_STATUS = C('LOAN_STATUS');
                    </php>
                    <span class="weui-form-preview__value">
                        {$LOAN_STATUS[$info['status']]} 
                        <php> 
                            $now=strtotime(date("Y-m-d"));
                            $ex_time=strtotime(date("Y-m-d",$info['expire_time']));
                            $int=$now-$ex_time>0?($now-$ex_time)/86400:0;
                            if($info['status']==5&&$int!=0){
                            $str="，已逾期".$int."天";
                        </php>
                        {$str}
                        <php>}</php>
                            
                        
                    </span>
                </div>


            </div>
           
        
        
    </div>

    <if condition="$info['status'] eq 5">
                <!-- <button class="weui-form-preview__btn weui-form-preview__btn_default login-btn  for_pay"  style="border:none;width:100%">延期还款</button> -->

                <input type="button"  value="延期还款" class="login-btn for_pay" style="width:80%;margin-left:10%;margin-top:25px;" />
                                <!-- <button class="chakan" style="position:absolute;left:43%;z-index:9;width:50px;height:50px;border-radius:25px;background:#D1EEEE;border:none;font-size:14px;">查看合同</button> -->
                <input type="hidden" id="hidden" value="{$info['id']}">




                <input type="button"  value="测试" class="css"  style="width:80%;margin-left:10%;margin-top:25px;" />



                <php>
                    $now=time();
                    $date = date('Y-m-d');
                    $time1 =strtotime($date.'10:55:00');
                    $time2 =strtotime($date.'11:05:00');
                    $time3 =strtotime($date.'16:55:00');
                    $time4 =strtotime($date.'17:05:00');

                    if(($now>=$time1&&$now<=$time2)||($now>=$time3&&$now<=$time4))
                    {
                </php>
                <input type="button"  value="立即还款" class="login-btn clz" style="width:80%;margin-left:10%;margin-top:10px;" />
                <!-- <button  class="weui-form-preview__btn weui-form-preview__btn_primary login-btn clz" style="border:none">立即还款</button> -->
                <php>}else{</php>
                <input type="button"  value="立即还款" class="login-btn for_pay" style="width:80%;margin-left:10%;margin-top:10px;" />
                <!-- <button class="weui-form-preview__btn weui-form-preview__btn_primary login-btn for_pay">立即还款</button> -->
                <php>}</php>

            </div>

    <elseif condition="$info['status'] eq 4"/>
        <?php
            if($info['order_num']!=0&&$info['oid_paybill']!=0){
        ?>
            <span>打款已提交，请耐心等候，若长时间资金无法到账，请联系客服处理</span>
            
        <?php
            }else{
        ?>
            <input type="hidden" id="hidden" value="{$info['id']}">
            <input type="button"  value="我已确认，可打款" class="payout"  style="width:80%;margin-left:10%;margin-top:25px;" />
        <?php
            }
        ?>





    </if>


    <div class="day" style="height:120%;width:100%;background:rgba(0,0,0,0.3);position:absolute;top:0;left:0;z-index:99;display:none">
        <div class="box" style="margin:auto;margin-top:25%;;width:75%;height:40%;background:#fff;box-shadow: 0px 0px 4px #666;border-radius:7px">
            <div class="cancle" style="height:21%;border-bottom:#ccc 1px solid;line-height:70px;background:#f5f5f7;border-top-left-radius:7px;border-top-right-radius:7px;">
                
                <span style="margin-left:30%;color:#465064;font-size:18px;text-align:center;line-height:55px;">选择延期天数</span>
            </div>
            <label style="height:30%;width:100%;float:left;border-bottom:1px solid #ccc">
                        <span style="font-size:17px;line-height:62px;margin-left:10px;color:#465064">7天</span> 
                <input type="radio" style="height:20px;width:20px;margin-top:20px;float:right;margin-right:5px;" name="day" checked value="7">
               
            </label>
            <label style="height:30%;width:100%;float:left;border-bottom:1px solid #ccc">
                        <span style="font-size:17px;line-height:62px;margin-left:10px;color:#465064">14天</span> 
                <input type="radio" style="height:20px;width:20px;margin-top:20px;float:right;margin-right:5px;" name="day"  value="14">
               
            </label>
            <label class="_sure" style="width:100%;height:25%;float:left;margin-left:40%;margin-top:3%"><input type="button" value="确定" style="border:none;background:#fff;color:#ee3a4a;font-size:18px;"></label>
        </div>
    </div>

    <div class="block" style="height:120%;width:100%;background:rgba(0,0,0,0.3);position:absolute;top:0;left:0;z-index:9;display:none">
        <div class="box" style="margin:auto;margin-top:25%;;width:75%;height:50%;background:#fff;box-shadow: 2px 2px 2px #666;border-radius:7px">
            

                <div class="cancle" style="height:21%;border-bottom:#ccc 1px solid;line-height:70px;background:#f5f5f7;border-top-left-radius:7px;border-top-right-radius:7px;">
                    <i style="float:left;width:16px;height:16px;background-image:url('__IMG__/cancle.png'); background-repeat:no-repeat; background-size:100% 100%;-moz-background-size:100% 100%;margin-left:26px;margin-top:24px"></i>
                    <span style="margin-left:40px;color:#465064;font-size:18px;text-align:left;">选择付款方式</span>
                </div>

               
                <div class="pay" style="height:60%;border-bottom:1px solid #ccc">
                    <label style="height:35%;width:100%;float:left;border-bottom:1px solid #ccc">
                        <php>
                            $OPEN_BANK =   C('OPEN_BANK');
                            foreach($OPEN_BANK as $k=>$v){
                                if($openbank==$k){
                                    $open=$v;
                                    $wh=substr($info['bank_card'],-4);
                                    break;
                                }
                            }
                        </php>

                        <i style="float:left;width:34px;height:34px;background-image:url('__IMG__/yinhang.png'); background-repeat:no-repeat; background-size:100% 100%;-moz-background-size:100% 100%;margin-left:20px;margin-top:11px"></i>
                        <span style="font-size:17px;line-height:62px;margin-left:10px;color:#465064">{$open}({$wh})</span> 
                        <input type="radio" style="height:20px;width:20px;margin-top:20px;float:right;margin-right:5px;" name="t" checked value="1">
                       
                    </label>
                    <label style="height:35%;width:100%;float:left;border-bottom:1px solid #ccc">
                        <i style="float:left;width:34px;height:34px;background-image:url('__IMG__/zfb.png'); background-repeat:no-repeat; background-size:100% 100%;-moz-background-size:100% 100%;margin-left:20px;margin-top:11px"></i>
                        <span style="font-size:17px;line-height:62px;margin-left:10px;color:#465064">支付宝</span> 
                        <input type="radio" style="height:20px;width:20px;margin-top:20px;float:right;margin-right:5px;" name="t"  value="2">
                       
                    </label>

                    <label style="height:15%;width:100%;float:left;color:#465064;text-align:center;font-size:12px;line-height:55px;">
                        <span style="font-size:17px;line-height:62px;margin-left:10px;color:#465064">更换银行卡还款</span> 
                        <input type="radio" style="height:20px;width:20px;margin-top:20px;float:right;margin-right:5px;" name="t" value="3">
                    </label>
                </div>
                <label class="sure" style="height:19%;width:100%;">
                    <span style="float:left;height:19%;width:100%;color:#ee3a4a;line-height:55px;font-size:21px;background:#fff;text-align:center">确定</span>
                    
                </label>
        </div>
        <form action="" method="post">
            <input type="hidden" id="zdhk" name="req_data" value=''>
        </form>
        
        
    </div>
<!-- <form action="" method="post">
            <input type="hidden" id="cs" name="res_data" value='{"oid_partner":"201103171000000000","dt_order":"20130515094013","no_order":"2013051500001","oid_paybill":"2013051613121201","money_order":"210.97","result_pay":"SUCCESS","settle_date":"20130516","sign_type":"RSA","sign":"ZPZULntRpJwFmGNIVKwjLEF2Tze7bqs60rxQ22CqT5J1UlvGo575QK9z/+p+7E9cOoRoWzqR6xHZ6WVv3dloyGKDR0btvrdqPgUAoeaX/YOWzTh00vwcQ+HBtXE+vPTfAqjCTxiiSJEOY7ATCF1q7iP3sfQxhS0nDUug1LP3OLk="}'>
            <button type="button" class="cs">测试按钮</button>
        </form> -->
    
</div>
</block>
<block name="script">

    


    <script>

    // $('.cs').click(function(){
    //     var val=$('#cs').val();
    //      $.ajax({
    //         type:'post',
    //         url:"{:U('llpay_notify')}",
    //         data:{'val':val},
    //         // dataType:'json',
    //         success:function(m){
    //             popup.alert(m)
    //         }
    //     });
    // })
 var select='';
 var id=$('#hidden').val();

$('.css').click(function(){
    $.ajax({
        type:'get',
        url:"http://weixin.jcsmkj.cn/index.php?m=weixin&c=user&a=query&uid=222",
        success:function(m){
            popup.alert(m)
        }
    })
})





   




    var day=0;
    
        $('.for_pay').click(function(){
            select=$(this).val();
            if(select=='延期还款'){
                $('.day').css('display','block');
                $('._sure').click(function(){
                    day=$('.day :checked').val();
                    $('.day').css('display','none');
                    $('.block').css('display','block');
                });

            }else{
                $('.block').css('display','block');
            }
            
           
        })
        //点击确定

        $('.sure').click(function(){
            
            var payment=$('.pay :checked').val();
            if(payment==3){   //主动还款
                $('form').attr('action','https://wap.lianlianpay.com/installment.htm');
                if(select=='延期还款'){

                    $.ajax({
                        type:'post',
                        url:"{:U('llpay')}",
                        data:{'id':id,'type':'delay','day':day},
                        dataType:'json',
                        success:function(m){
                            
                            $('#zdhk').val(m);
                            $("form").submit();
                        }
                    });
                    
                }else if(select=='立即还款'){ 
                    $.ajax({
                        type:'post',
                        url:"{:U('llpay')}",
                        data:{'id':id,'type':'promptly'},
                        dataType:'json',
                        success:function(m){
                            // popup.alert(m)

                            $('#zdhk').val(m);
                            $("form").submit();
                        }
                    });
                }
                
                
            }else if(payment==2){       //支付宝   {:U('alipay?type=promptly&id='.$info['id'])}       
                if(select=='延期还款'){
                    location.href="{:U('alipay?type=delay&id=')}"+id+'&day='+day;
                }else if(select=='立即还款'){ 
                    // alert()
                    id=$('#hidden').val();
                    location.href="{:U('alipay?type=promptly&id=')}"+id;
                }
            }else{
                // 提前还款  使用已绑定的银行卡还款
                if(select=='延期还款'){
                    popup.alert('延期费用不支持该支付方式！')
                    
                }else if(select=='立即还款'){ 
                    id=$('#hidden').val();

                    $.ajax({
                        type:'post',
                        url:"{:U('agreenoauthapply')}",
                        // url:"{:U('signApply')}",
                        data:{'id':id},
                        dataType:'json',
                        success:function(m){
                            confirm(m.info)
                            location.reload();

                        }
                    });
                }
            }
        });


        //点击隐藏
        $(".box").click(function(e){
            $(this).show();
            e.stopPropagation();//阻止冒泡
        });
        $('.block').click(function(){
            $(".block").hide();
         
        })


        $('.clz').click(function(){
             popup.alert('批扣处理中，暂不能主动支付');
         })

        $('.chakan').click(function(){
             location.href="http://weixin.jcsmkj.cn/index.php?m=weixin&c=capital&a=agreement&show=1&id="+id;
        })




        $('.payout').click(function(){

            $.ajax({
                type:'post',
                data:{'id':id},
                url:"{:U('payout')}",
                success:function(m){
                    if(m==1){
                        popup.alert('打款提交成功，请耐心等候资金到账！');
                        setTimeout(function(){
                            location.reload();
                        },1000);
                    }else{
                        popup.alert('打款申请提交失败，原因是：'+m+',可截图此原因至客服处理');
                    }
                }
            })
            
        })
    </script>

</block>

﻿﻿﻿

